import javax.swing.*;
import java.awt.*;
import java.util.LinkedList;

public class EnemyObject {
    LinkedList<Player> enemyLinked = new LinkedList<Player>();
    public void render(Graphics g) {
        g.setColor(Color.red);
        for(int i = 0; i < enemyLinked.size(); i++){
            Player tempObject = enemyLinked.get(i);
            tempObject.render(g);
        }
    }

    public void tick() {
        for(int i = 0; i < enemyLinked.size(); i++){
            Player tempObject = enemyLinked.get(i);
             tempObject.tick();
        }
        isMonsterDeath();
    }
    public void isMonsterDeath(){
        for(int i = 0; i < enemyLinked.size(); i++){
            if (enemyLinked.get(i).getHP()<=0){
                enemyLinked.remove(i);
                JOptionPane.showMessageDialog(null,"Monster Death");
            }
        }

    }
    public void enemyMove(GameStats gameStats,java.awt.event.MouseEvent e,PlayerObject playerObject ,EnemyObject enemyObject) throws InterruptedException {
        for(int i = 0; i < enemyLinked.size(); i++){
            Player tempObject = enemyLinked.get(i);
            tempObject.enemyMove(e,playerObject,enemyObject);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e1) {
                e1.printStackTrace();
            }
        }
        gameStats.NOWSTATS= gameStats.PLAYERTURN;
        JOptionPane.showMessageDialog(null,"玩家的回合");
    }

    public void addPlayer(Player object){
        this.enemyLinked.add(object);
    }
    public void removePlayer(Player object){
        this.enemyLinked.remove(object);
    }
}

